package com.example.biketask.service.impl;

import com.example.biketask.dao.Opt2Mapper;
import com.example.biketask.dao.OptUserMapper;
import com.example.biketask.pojo.UserOperation;
import com.example.biketask.pojo.ZoomOperation;
import com.example.biketask.service.ZoomService;
import com.example.biketask.util.DataStyle;
import com.example.biketask.util.IPUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;


@Repository
public class ZoomServiceImpl implements ZoomService {

    @Autowired
    OptUserMapper optUserMapper;

    @Autowired
    Opt2Mapper opt2Mapper;

    @Override
    public void add_zoom_option(int optType, ZoomOperation zoomOperation) {

        //创建UserOperation
        UserOperation userOperation = new UserOperation();

        //获取用户ip地址
        String ipAddr = IPUtils.getIpAddr();

        //获取当前时间
        DataStyle dataStyle = new DataStyle();

        //赋值UserOperation
        userOperation.setOptType(optType);
        userOperation.setUserIp(ipAddr);
        userOperation.setCreateTime(dataStyle.DataStyle());

        optUserMapper.userOperation(userOperation);

        zoomOperation.setOptId(userOperation.getId());

        opt2Mapper.insert_bt_03(zoomOperation);
    }
}
